'''----登录函数----
编写一个用户登录逻辑，用户名密码提前设置（列表嵌套字典存储），返回用户登录成功或者失败的结果。'''

import time
user1 = {'id':'1001','username':'zhangsan','password':'123'}
user2 = {'id':'1002','username':'lisi','password':'123'}
user3 = {'id':'1003','username':'wangwu','password':'123'}
user_list = [user1,user2,user3]
while True:
    un=input('请输入用户名：')
    pw=input('请输入密码')
    for user in user_list:
        if un==user['username'] and pw==user['password']:
            tag =1
            break
        else:
            tag=2

    if tag==1:
        time.sleep(0.5)
        print('登陆成功！')
        break
    else:
        time.sleep(0.5)
        print('!'*20+'请输入正确的用户名/密码!！'+'!'*20)
        time.sleep(1)
        continue